package org.example.controller.oaa;

import org.example.dao.commom.Result;
import org.example.dao.commom.ResultCode;
import org.example.dao.entity.market.CBusiness;
import org.example.service.oaa.LoginService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author xluo
 * @date 2023/10/30 11:15
 */
@RestController
@CrossOrigin
@RequestMapping("/oaa/business")
public class LoginController {

    @Resource
    private LoginService loginService;

    /**
     * 商户登录
     */
    @PostMapping("/login")
    public Result Login(@RequestBody CBusiness business) {
        String username = business.getUsername();
        String password = business.getPassword();
        String token = loginService.login(username, password);
        return new Result(ResultCode.SUCCESS, token);
    }

    /**
     * 验证token
     */
    @PostMapping("/verify")
    public Result verify(@RequestBody String token) {
        token = loginService.verify(token);
        return new Result(ResultCode.SUCCESS, token);
    }

}
